package com.cecsmsserve.mapper;

import com.cecsmsserve.entity.UserActivity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cecsmsserve.entity.vo.MyActivity;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 王郝浠
 * @since 2024-04-22
 */
public interface UserActivityMapper extends BaseMapper<UserActivity> {

    @ResultMap("userActivityMap")
    @Select("select * from user_activity")
    List<UserActivity> selectAll();

    @ResultMap("userActivityMap")
    @Select("select  * from user_activity limit #{arg0},#{arg1}")
    List<UserActivity> selectAllByPage(int start, int size);

    //    @ResultMap("userActivityMap")
//    @Select("select * from user_activity where uId=#{uId}")
    List<MyActivity> selectAllByuId(int uId);

//    @ResultMap("userActivityMap")
//    @Select("select * from user_activity where uId=#{arg0} and state=#{arg1}")
    List<MyActivity> selectByUIdBymyState(int uId,String state);

//    @ResultMap("userActivityMap")
//    @Select("select m.* from user_activity m join activity a on m.aid=a.id where m.uid=#{uId} and a.state=#{state}")
    List<MyActivity> selectByUIdByState(int uId, String state);

    @Select("select * from user_activity where uId=#{arg0} and aId=#{arg1}")
    UserActivity selectByuIdByaId(int uId, int aId);

    @Select("select uId from user_activity where aId=#{aId} and state=\"报名成功\" order by uId")
    List<Integer> selectUserByaId(int aId);
}
